﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
using System;
using SqlSugar;
using System.Configuration;
using System.Threading;
namespace Exercise
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // IConfiguration Configuration
                IConfiguration Configuration = new ConfigurationBuilder()
            .Add(new JsonConfigurationSource { Path = @"app.json", ReloadOnChange = true })
            .Build();
                Console.WriteLine("类文件正在生成....");
                string connStr = Configuration["ConnectionStrings:connStr"];// ("connStr");
                //string  constr= Configuration.GetConnectionString("connStr"); 第二种访问节点的方式
                string path = Configuration["Appsettings:Path"];
                string partialPath = Configuration["Appsettings:PartialPath"];
                SqlSugarClient db = new SqlSugarClient(connStr);
                db.DbFirst.IsCreateAttribute().CreateClassFile(path);
                Console.WriteLine("实体类生成完毕，生成接口PartialClass....");
                db.DbFirst.IsCreateAttribute().CreateClassPartialFile(partialPath);
                Console.WriteLine("PartialClass类文件生成完成，即将退出....");
                int i = 2;
                while (i >= 0)
                {
                    Console.SetCursorPosition(0, 3);
                    Console.Write(i);
                    Thread.Sleep(1000);
                    i--;
                }
                // Thread.Sleep(2000);
                //Console.ReadLine();
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }


    }


}
